package com.yi.apipassenger.controller;

import com.yi.apipassenger.service.UserService;
import com.yi.internalcommon.dto.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class UserController {


    @Autowired
    private UserService userService;
    @GetMapping("/users")
    public ResponseResult getUser(HttpServletRequest request){
        //从请求中获取accesstoken
        String accessToken = request.getHeader("Authorization");
        //根据accesstoken查询
        ResponseResult userByAccessToken = userService.getUserByAccessToken(accessToken);
        return  userByAccessToken;
    }
}
